const express = require('express');
const cors = require('cors');
const mongoose = require('mongoose');

const app = express();
const port = 3000;

// 中间件
app.use(cors());
app.use(express.json());

// 测试路由
app.get('/test', (req, res) => {
  res.json({ message: 'Express server is working!' });
});

app.get('/bkc/test', (req, res) => {
  res.json({ message: 'BKC route is working!' });
});

// 启动服务器
app.listen(port, () => {
  console.log(`Test server running on port ${port}`);
  console.log(`Test URL: http://localhost:${port}/test`);
  console.log(`BKC test URL: http://localhost:${port}/bkc/test`);
});

// 测试数据库连接
mongoose.connect('mongodb+srv://2334231668:xin123666@cluster0.13va5ah.mongodb.net/2410b2')
  .then(() => {
    console.log('✅ MongoDB connected successfully');
  })
  .catch((err) => {
    console.error('❌ MongoDB connection failed:', err.message);
  });



